package com.zsj.zsjkotlinmvvm.utils;

import android.app.Application;
import android.content.Context;

import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
import com.shuyu.gsyvideoplayer.player.SystemPlayerManager;


public class CarGuo {
    private static volatile CarGuo instance = null;

    public static CarGuo getInstance() {
        CarGuo result = instance;
        if (result == null) {
            synchronized (CarGuo.class) {
                result = instance;
                if (result == null) {
                    instance = result = new CarGuo();
                }
            }
        }
        return result;
    }

    private Context applicationContext;
    private final boolean showDefinition = true;//是否显示清晰度切换按钮 默认显示

    public void init(Application application) {
        applicationContext = application.getApplicationContext();

        //视频播放采用内核
        if (FlavorUtils.isIjk()) {
            PlayerFactory.setPlayManager(IjkPlayerManager.class);
        } else if (FlavorUtils.isSystem()) {
            PlayerFactory.setPlayManager(SystemPlayerManager.class);
        } else {
//            PlayerFactory.setPlayManager(Exo2PlayerManager.class);
        }
    }

    public Context getApplicationContext() {
        return applicationContext;
    }

    public boolean isShowDefinition() {
        return showDefinition;
    }

}
